package com.celan.year2023.month05.day03;

/**
 * @author Celan
 * @ClassName Solution
 * @description: TODO
 * @date 2023/05/03
 * @version: 1.0
 */
class Solution {
    public boolean isValid(String s) {
        StringBuilder stack = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            stack.append(c);
            if (stack.length() >= 3 && stack.substring(stack.length() - 3).equals("abc")) {
                stack.delete(stack.length() - 3, stack.length());
            }
        }
        return stack.length() == 0;
    }
}
